package com.hq.vieorecyclerview.video.Adapter;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 视频数据保存
 */
public class VideoModel  extends ViewModel implements Runnable {
    //线程池
    private final ExecutorService netexe;
    //视频数据
    private MutableLiveData<List<VideoDate>> vdate = null;
    public VideoModel(){
        //初始化数据实力
        this.vdate = new MutableLiveData<List<VideoDate>>();
        this.netexe = Executors.newSingleThreadScheduledExecutor();
        List<VideoDate> list=new ArrayList<>();
        this.vdate.setValue(list);
    }
    @Override
    public void run() {
        //图片更新
        String gif = "https://5b0988e595225.cdn.sohucs.com/images/20190721/67d2edceaecf4fa690c9a37fe37ddb40.gif";
        for (int i = 0; i < 100; i++) {
            VideoDate td = new VideoDate();
            td.setName("干嘛");
            td.setPlaytemp("2:34:44");
            td.setImage(gif);
            this.getDate().add(td);
        }
    }
    //视频数据更新
    public void update(){
        this.netexe.submit(this);
    }
    public List<VideoDate> getDate(){
        return this.vdate.getValue();
    }
}
